﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Regions;
using VpPrism.Modules.ModuleOne.ViewModels;
using VpPrism.Common;

namespace VpPrism.Modules.ModuleOne.Controllers
{
  /// <summary>
  /// Controller du ModuleOne
  /// </summary>
  public class ModuleOneMainController: IModuleOneMainController
  {
    #region Fields
    private readonly IUnityContainer container;
    private readonly IRegionManager regionManager;
    private readonly IModuleOneMainVM moduleOneMainVM;
    #endregion

    #region Constructor
    /// <summary>
    /// Constructeur. Les paramètres sont pré-remplis par le UnityContainer.
    /// </summary>
    /// <param name="container"></param>
    /// <param name="regionManager"></param>
    /// <param name="moduleOneMainVM"></param>
    public ModuleOneMainController(IUnityContainer container, IRegionManager regionManager, IModuleOneMainVM moduleOneMainVM)
    {
      this.container = container;
      this.regionManager = regionManager;
      this.moduleOneMainVM = moduleOneMainVM;
    }
    #endregion

    #region IModuleOneMainController Members

    /// <summary>
    /// Lance le Controller: Injecte la vue dans la région
    /// </summary>
    public void Run()
    {
      this.regionManager.RegisterViewWithRegion(RegionNames.RegionOne, 
                                        () => this.moduleOneMainVM.MainView);
    }

    #endregion
  }
}
